package com;

import com.interceptor.MethodInterceptor;
import com.interceptor.impl.AfterInterceptor;
import com.interceptor.impl.AroundInterceptor;
import com.interceptor.impl.BeforeInterceptor;
import com.invocation.impl.DefaultMethodInvocation;
import com.service.UserService;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;

public class Application {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        ArrayList<MethodInterceptor> methodInterceptorList = new ArrayList<>();
        methodInterceptorList.add(new AroundInterceptor());
        methodInterceptorList.add(new BeforeInterceptor());
//        methodInterceptorList.add(new AroundInterceptor());
        methodInterceptorList.add(new AfterInterceptor());

        UserService userService = new UserService();
        Method loginMethod = UserService.class.getMethod("add");
        new DefaultMethodInvocation(methodInterceptorList,loginMethod,userService).process();
    }
}
